<template>
  <div
    class="Video-container"
    style="
      display: flex;
      flex-direction: column;
      height: 100vh;
      box-sizing: border-box;
    "
  >
    <!-- 顶部导航 -->
    <nav-bar
      :title="VideoDetail.name"
      left-text=""
      left-arrow
      @click-left="onClickLeft"
    >
      <template #right>
        <cell @click="showShare = true">
          <i
            class="fa fa-share"
            aria-hidden="true"
            style="
              width: 1rem;
              height: 1rem;
              background-color: #fff;
              color: #333;
              font-size: 0.75rem;
              text-align: center;
              line-height: 1rem;
              border-radius: 0.2rem;
            "
          ></i>
        </cell>
        <share-sheet
          v-model:show="showShare"
          title="分享到"
          :options="options"
          @select="onSelect"
        />
      </template>
    </nav-bar>
    <!-- 顶部 -->
    <div
      class="Video-top"
      style="width: 100vw;"
    >
  <img :src="VideoDetail.picture" alt="" style="width: 100%;">
  </div>
    <!-- 主要内容 -->
    <div
      class="Video-main"
      style="flex: 1; background-color: aliceblue; overflow: auto"
    >
      <tabs v-model:active="active" swipeable>
        <!-- 课程介绍 -->
        <tab :title="'课程介绍'">
          <div
            style="
              height: 13vh;
              background-color: white;
              margin-top: 0.2rem;
              display: flex;
              justify-content: space-evenly;
              flex-direction: column;
              padding: 0.2rem 0.7rem;
            "
          >
            <div style="display: flex; justify-content: space-between">
              <span>{{VideoDetail.name}}</span>

              <cell @click="showShare = true">
                <i
                  class="fa fa-share"
                  aria-hidden="true"
                  style="
                    width: 1rem;
                    height: 1rem;
                    background-color: #1798fa;
                    font-size: 0.75rem;
                    text-align: center;
                    line-height: 1rem;
                    color: white;
                    border-radius: 0.2rem;
                  "
                ></i>
              </cell>
              <share-sheet
                v-model:show="showShare1"
                title="分享到"
                :options="options1"
                @select="onSelect1"
              />
            </div>
            <div>
              <span
                ><rate v-model="value" allow-half /><i
                  style="
                    font-style: normal;
                    margin-left: 0.5rem;
                    font-size: 0.75rem;
                    margin-right: 1.2rem;
                  "
                  >4.5</i
                ></span
              ><span style="font-size: 0.75rem">205033人学过</span>
            </div>
            <div style="font-size: 0.75rem">
              <span style="margin-right: 1.5rem"
                ><i
                  style="margin-right: 0.3rem"
                  class="fa fa-user"
                  aria-hidden="true"
                ></i
                >主讲：<span>{{VideoDetail.teacher}}</span></span
              ><span style="margin-right: 1.5rem"
                ><i
                  style="margin-right: 0.3rem"
                  class="fa fa-caret-square-o-right"
                  aria-hidden="true"
                ></i
                >视频：5集</span
              ><span style="margin-right: 1.5rem"
                ><i
                  style="margin-right: 0.3rem"
                  class="fa fa-briefcase"
                  aria-hidden="true"
                ></i
                >习题：38题</span
              >
            </div>
          </div>
          <!-- 简介 -->
          <div
            style="
              height: 13vh;
              background-color: white;
              margin-top: 0.4rem;
              padding: 0.5rem 0.7rem;
              box-sizing: border-box;
            "
          >
            <p style="font-size: 0.8rem">课程简介</p>
            <div style="font-size: 0.75rem; color: #999; margin-top: 0.5rem">
              {{VideoDetail.Introduction}}
            </div>
          </div>
        </tab>
        <!-- 视频列表 -->
        <tab :title="'视频列表'">
          <div
            style="
              background-color: white;
              margin-top: 0.2rem;
              font-size: 0.75rem;
              color: #999;
              padding: 0 0.5rem;
            "
          >
            <!-- 标题 -->
            <div
              style="
                height: 2.5rem;
                line-height: 2.5rem;
                box-sizing: border-box;
                display: flex;
                justify-content: space-between;
                border-bottom: 0.0625rem solid #999;
              "
            >
              <span><i style="color: #333">5集</i><i>（已全部更新）</i></span>
              <span
                style="
                  width: 3rem;
                  display: flex;
                  justify-content: space-between;
                  align-items: center;
                "
              >
                <i
                  class="fa fa-share"
                  aria-hidden="true"
                  style="
                    width: 1rem;
                    height: 1rem;
                    background-color: #1798fa;
                    font-size: 0.75rem;
                    text-align: center;
                    line-height: 1rem;
                    color: white;
                    border-radius: 0.2rem;
                  "
                ></i>
                <i
                  class="fa fa-arrow-circle-down"
                  aria-hidden="true"
                  style="font-size: 1.2rem; color: #1798fa"
                ></i>
              </span>
            </div>
            <!-- 列表 -->
            <div
              v-for="i in VDetail"
              style="
                height: 2.5rem;
                line-height: 2.5rem;
                box-sizing: border-box;
                display: flex;
                justify-content: space-between;
                border-bottom: 0.0625rem solid #999;
              "
            >
              <span
                ><i
                  style="
                    width: 1rem;
                    height: 1rem;
                    border: #1798fa solid 0.0625rem;
                  "
                  ><icon
                    name="back-top"
                    style="transform: rotate(180deg); color: #1798fa" /></i
                ><i style="text-indent: 0.9375rem;display: inline-block;">{{i.name}}</i></span
              >
              <span
                style="
                  width: 3rem;
                  display: flex;
                  justify-content: space-between;
                  align-items: center;
                "
              >
                <i
                  class="fa fa-pencil"
                  aria-hidden="true"
                  style="
                    width: 1rem;
                    height: 1rem;
                    font-size: 1rem;
                    text-align: center;
                    line-height: 1rem;
                    color: white;
                    color: #666;
                    border-radius: 0.2rem;
                  "
                ></i>
                <icon name="more" />
              </span>
            </div>
          </div>
        </tab>
        <!-- 提问 -->
        <tab :title="'提问'">
          <div>
            <div style="margin-top: 0.1rem">
              <notice-bar
                :scrollable="false"
                text="温馨提示：灌水、带有反动的言论会被删除，严重者封号处理，谢谢配合！"
                style="font-size: 0.75rem"
              />
            </div>
            <div
              style="
                height: 4rem;
                background-color: white;
                padding: 0.5rem;
                font-size: 0.75rem;
                box-sizing: border-box;
              "
            >
              <p>选择视频</p>
              <button style="background-color: #1798fa; color: white">
                01
              </button>
              <button>02</button>
              <button>03</button>
              <button>04</button>
              <button>05</button>
            </div>
            <div style="background-color: white; margin-top: 0.3rem">
              <div style="padding: 0.5rem">
                <span
                  style="
                    width: 1.5rem;
                    height: 0.75rem;
                    font-size: 0.75rem;
                    border: #1798fa 0.0625rem solid;
                    border-radius: 0.3rem;
                    text-align: center;
                    line-height: 0.75rem;
                    color: #1798fa;
                    display: inline-block;
                  "
                  >01</span
                >
                <span
                  style="
                    display: inline-block;
                    margin-left: 0.5rem;
                    font-size: 0.9rem;
                    color: #1798fa;
                  "
                  >陨落的天才少年--《伤仲永》</span
                >
                <span
                  style="
                    display: inline-block;
                    color: #999;
                    font-size: 0.75rem;
                    margin-left: 1rem;
                  "
                  >评论（147）</span
                >
              </div>
              <!-- 评论列表 -->
              <div
                style="display: flex; padding: 0.5rem; font-size: 0.75rem"
                v-for="i in 100"
              >
                <div
                  style="
                    width: 2rem;
                    height: 2rem;
                    border-radius: 1rem;
                    border: 1px solid #333;
                  "
                >
                  <img src="" alt="头像" />
                </div>
                <div
                  style="
                    flex: 1;
                    display: flex;
                    flex-direction: column;
                    justify-content: space-evenly;
                    margin-left: 0.5rem;
                    border-bottom: 1px solid #999;
                  "
                >
                  <div
                    style="
                      display: flex;
                      justify-content: space-between;
                      color: #999;
                    "
                  >
                    <span style="display: flex; flex-direction: column">
                      <i>mico</i>
                      <i>等级14：大亨（声名显赫）</i>
                    </span>
                    <span>日期</span>
                  </div>
                  <p style="margin: 0.6rem 0">
                    评论评论评论评论评论评论评论评论评论评论
                  </p>
                  <div style="color: #999; margin-bottom: 0.5rem">
                    <span
                      ><i
                        class="fa fa-comment-o"
                        aria-hidden="true"
                        style="font-size: 1rem"
                      ></i
                      ><i>17</i></span
                    ><span style="margin-left: 1rem"
                      ><icon name="good-job-o" /><i>33</i></span
                    >
                  </div>
                </div>
              </div>
            </div>
          </div>
        </tab>
      </tabs>
    </div>
    <!-- 底部 -->
    <div
      class="Video-bottom"
      style="height: 6vh; line-height: 6vh; font-size: 0.8rem"
    >
      <router-link :to="{ name: 'Home-Cart' }">
        <div style="width: 50%; float: left; text-align: center">
          加入购物车
        </div>
      </router-link>

      <div
        style="
          width: 50%;
          float: right;
          display: flex;
          justify-content: center;
          background-color: #1798fa;
        "
         @click="OrderHandle(Orders.id)"
      >
        <span style="color: white; font-weight: bolder">购买</span>
        <span style="color: orange; margin: 0 0.2rem"
          ><i class="fa fa-copyright" style="margin: 0 0.2rem"></i><span>{{Orders.price}}</span></span
        >
        <span
          style="
            font-size: 0.75rem;
            margin-left: 0.3rem;
            color: #666;
            text-decoration: line-through;
          "
          ><i
            class="fa fa-copyright"
            style="text-decoration: line-through; margin-right: 0.1rem"
          ></i
          >{{Orders.price}}</span
        >
      </div>
    </div>
  </div>
</template>
<script setup>
import { Tab, Tabs, Rate, Icon, NoticeBar, NavBar, ShareSheet } from "vant";
import { ref } from "vue";
import "font-awesome/css/font-awesome.min.css";
import { ComboTreeDetailAPI } from "../API/wang";
import { useRoute, useRouter } from "vue-router";
const route = useRoute(); //获取路由中的参数
const router = useRouter();
const VideoDetail = ref([]); //数据//顶部数据
const VDetail = ref([]); //数据
const Orders = ref([]);//取跳转订单页id
//console.log(route.query.id);
const loadVideoData = async () => {
  const data = await ComboTreeDetailAPI(route.query.id);
  //console.log(data);
  //顶部数据
  VideoDetail.value = data.data[0].children[0];
  //console.log(VideoDetail.value);
  //主要内容
  VDetail.value = data.data[0].children[0].children;
  //console.log(VDetail.value);
  //跳转订单页
  Orders.value = data.data[0];
  console.log(Orders.value);
};
/* 跳转订单页 */
const OrderHandle = (id) =>{
  router.push({
    name:'Home-Orders',
    query:{
      id,
    }
  })
}
loadVideoData();
//返回上一级
const onClickLeft = () => history.back();
//分享1
const showShare = ref(false);
const options = [
  { name: "微信", icon: "wechat" },
  { name: "微博", icon: "weibo" },
  { name: "微博", icon: "weibo" },
  { name: "QQ", icon: "qq" },
];

const onSelect = (option) => {
  Toast(option.name);
  showShare.value = false;
};
//分享2
const showShare1 = ref(false);
const options1 = [
  { name: "微信", icon: "wechat" },
  { name: "微博", icon: "weibo" },
  { name: "微博", icon: "weibo" },
  { name: "QQ", icon: "qq" },
];

const onSelect1 = (option) => {
  Toast(option.name);
  showShare1.value = false;
};
/* 评分 */
const value = ref(3.5);
</script>
<style>
#app {
  padding-bottom: 0;
}
/* 顶部导航 */
.Video-container .van-nav-bar .van-icon {
  color: #333;
}
/* Video-main */
.Video-main .van-rate__icon--full {
  color: #1798fa;
}
.Video-main .van-rate__icon {
  font-size: 0.75rem;
  width: 1rem;
}
.Video-main .van-icon {
  font-size: 1.2rem;
}
.Video-container .van-share-sheet__options {
  justify-content: space-evenly;
}
.Video-main button {
  border: none;
  color: #999;
  margin-top: 0.2rem;
  margin-right: 0.3rem;
  width: 2rem;
  height: 1.5rem;
  border-radius: 0.3rem;
}
i {
  font-style: normal;
}
a {
  color: #333;
}
</style>
